package com.example.custcomsumer.controller;

import com.example.custcomsumer.entity.BigEvent;
import com.example.custcomsumer.service.CustBehaveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("behave-consumer")
@CrossOrigin
public class CustBehaveConsumerController {

    @Autowired
    private CustBehaveService custBehaveService;

    @GetMapping("/selectNormal/{currentPage}/{pageSize}")
    public List<BigEvent> selectNormal(@PathVariable("currentPage") int currentPage, @PathVariable("pageSize") int pageSize) {
        return custBehaveService.selectNormal(currentPage, pageSize);
    }

    @GetMapping("/selectAbnormal/{currentPage}/{pageSize}")
    public List<BigEvent> selectAbnormal(@PathVariable("currentPage") int currentPage, @PathVariable("pageSize") int pageSize) {
        return custBehaveService.selectAbnormal(currentPage, pageSize);
    }

    @GetMapping("/getNormalSum")
    public Integer getNormalSum() {
        return custBehaveService.getNormalSum();
    }

    @GetMapping("/getAbnormalSum")
    public Integer getAbnormalSum() {
        return custBehaveService.getAbnormalSum();
    }

    @GetMapping("/setAbnormal/{id}")
    public void setAbnormal(@PathVariable("id") String id) {
        int realID  = Integer.parseInt(id);
        custBehaveService.setAbnormal(realID);
    }

    @GetMapping("/cancelAbnormal/{id}")
    public void cancelAbnormal(@PathVariable("id") String id) {
        int realID  = Integer.parseInt(id);
        custBehaveService.cancelAbnormal(realID);
    }
}
